import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int n=scanner.nextInt();
        String s1=scanner.next();
        String s2=scanner.next();
        Solution solution=new Solution();
        System.out.println(solution.minDistance(s1,s2));
    }

    public static void main2(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int n=scanner.nextInt();
        int[] array=new int[100];
        for (int i = 0; i < n; i++) {
            array[i]=scanner.nextInt();
        }
        Solution2 solution2=new Solution2();
        System.out.println(solution2.maxSubArray(array));
    }

    public static void main1(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int n=scanner.nextInt();
        int[] array=new int[100];
        for (int i = 0; i < n; i++) {
            array[i]=scanner.nextInt();
        }
        Solution1 solution1=new Solution1();
        System.out.println(solution1.countSubarrays(array));
    }
}

class Solution {
    public int minDistance(String word1, String word2) {
        int res=0;
        int n=word1.length();
        int m=word2.length();
        

    }
}

class Solution2 {
    public int maxSubArray(int[] nums) {
        int n=nums.length;
        int[]dp=new int[n];
        dp[0]=nums[0];
        for (int i = 1; i <n ; i++) {
            dp[i]=Math.max(dp[i-1]+nums[i],nums[i]);
        }
        Arrays.sort(dp);
        return dp[n-1];
    }
}

class Solution1 {
    public int countSubarrays(int[] nums) {
        int n=nums.length;
        int res=0;
        for (int i = 1; i < n-1; i++) {
            if(nums[i]==(nums[i-1]+nums[i+1])*2)
                res++;
        }
        return res;
    }
}